package com.qf.flash.mvp.presenter;

import com.qf.dblib.dao.impl.UserMgr;
import com.qf.flash.http.HttpManager;
import com.qf.flash.model.TeamMateBean;
import com.qf.flash.mvp.contract.GroupListContract;
import com.qf.flashlib.base.BasePresenter;
import com.qf.flashlib.base.BaseResponse;
import com.qf.flashlib.base.BaseSubscriber;
import com.qf.flashlib.util.RxUtils;

import java.util.List;

public class GroupListPresenter extends BasePresenter<GroupListContract.View> implements GroupListContract.Presenter {
    @Override
    public void getGroupList(int pageNo, int pageSize) {
        String id = UserMgr.getInstance().getLoginUser().getUid();
            addSubscription(HttpManager.getInstance().getGsonHttpApi()
            .GET_MY_GROUPLIST(id,pageNo,pageSize)
                    .compose(RxUtils.handleBaseResult())
                    .compose(RxUtils.io_main())
                    .subscribeWith(new BaseSubscriber<BaseResponse<List<TeamMateBean>>>(mRootView) {
                        @Override
                        public void onSuccess(BaseResponse<List<TeamMateBean>> listBaseResponse) {
                            mRootView.setMyMate(listBaseResponse.getData(),listBaseResponse.getTotalPage());
                        }
                    })
            );
    }
}
